Chris Pollett > Old Classes >
CS116a

( Print View )

Student Corner:
  [Grades Sec1]

  [Submit Sec1]

  [Email List Sec1]

  [
Lecture Notes]

Course Info:
  [Texts & Links]
  [Topics]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]

Practice Exams:
  [Mid1]  [Mid2]  [Final]

                           












HW#2 --- last modified March 02 2019 21:08:06..

Solution set.

Due date: Oct 6

Files to be submitted:
  bitfill.cpp
  intext.cpp

Purpose:To gain experience with OpenGL bitmaps, fill area functions, display lists, and line attributes. To implement interior/exterior algorithms and experiment with outline fonts.

Specification:

When I was 5 years old my parents worked in Moose Factory in Northern Ontario, Canada. We lived there for a few months, and I remember being very interested in the characters used in the Cree syllabary. The Inuktitut syllabary, which was adapted from Cree, has several more complicated symbols. For this homework, we will use some of these symbols to learn about graphics and OpenGL.

The first program you will need to turn in is called bitfill.cpp . For this program create by hand a 13X13 bitmap for the symbol for vaa in Inuktitut and draw it in a 400x400 window three times horizontally starting at location (50, 300). Leave a two pixel space between times you draw your bitmap. You are allowed only one call to a glRasterPos* type function to do this part of the drawing. Next starting at location (50,100) draw the Inuktitut symbol for ji three times. For this latter, symbol rather than use a bitmap I want you to create a display list that specifies the symbol but does not specify the color to display it with. Your display list should store the character so that it is 150X150 pixels in size and I want the display list to use glRect once, GL_QUADS once, and then GL_LINE_STRIP for the remaining part of the figure. When you represent your lines makes them at least 10 pixels thick and use GL_LINE_STIPPLE mode. When you now use your display list three times to draw the three ji's, draw the characters so that they overlap with each other. The first ji should be drawn in red, the second in green, and the third in blue. I want you to enable GL_BLEND when doing the drawing and I want you to set the source and destination blend factors so that the blending is 0.5 mix (use GL_SRC_ALPHA and then having that alpha value .5).

For the second program, intext.cpp, I want you to create your own outline font for the Inuktitut symbol ngii. I leave the specifics of the representation up to you; however, like figure 3-62 (b) in the book there should be a well defined interior and exterior to your figure. To be more specific the width of the ``stroke'' must be at least 5% of the height of the figure. When your program is executed it looks for the file parameters.txt in the current directory, it opens the file and reads it. The first line of this file has two numbers separated by a space. These specify the x,y dimensions of the window respectively. After this line comes two lines each with x and y coordinates each separated by a single space. An example file might look like:

400 400
30 30
180 170

Your program creates a window of the specified size. It then draws in this window the symbol ngii scaled to fill as much of the window a possible. Next it plots the first point given in the file in the color red. You should draw this point large enough so that it is clearly visible. Finally, the second point should be plotted in either red or blue depending on the following criteria: If both points are interior or exterior to the character draw the point in red. Otherwise, draw the point in blue. To determine the interior/exterior property I want you to use either the odd-even rule or the nonzero winding number test.

Point Breakdown

Departmental coding guidelines for C++ followed 1pt
Vaa symbol drawn three times as described above 2pts
Ji symbol drawn three times as described above 2pts
intext.cpp reads file correctly 1pt
Symbol ngii scales with size of window 2pts
Points drawn in correct color and used either odd-even rule or nonzero winding number test2pts
Total10pts